www.gusucode.com > VC++ 更改文件属性为只读系统或隐藏源码程序 > VC++ 更改文件属性为只读系统或隐藏源码程序\code\TextDisp.cpp

    // TextDisp.cpp : implementation file
// download by http://www.NewXing.com

#include "stdafx.h"
#include "TextDisp.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CTextDisp

CTextDisp::CTextDisp()
{
}

CTextDisp::~CTextDisp()
{
}


BEGIN_MESSAGE_MAP(CTextDisp, CEdit)
	//{{AFX_MSG_MAP(CTextDisp)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTextDisp message handlers

void CTextDisp::FillTextDisp(CString strFilename)
{
	CStdioFile	f;
	CString		strTemp;
	CString		str;
	BOOL		flag;
	int			count = 10;

	if (!f.Open(strFilename, CFile::modeRead))
	{
		MessageBox("Open File Fail!");
		return ;
	}

	flag = f.ReadString(strTemp);
	while (flag && count--)
	{
		str += strTemp + "\r\n";
		flag = f.ReadString(strTemp);
	}

	if (flag)
		str += "...(下略)";

	SetWindowText(str); 
	f.Close(); 
}